<!--{include header_html}-->	
<script language="javascript">
	//检查表单数据的合法性
	function formCheck()
	{
		if($('#item_username').val() == '')
		{
			messageError('请填写登录名！');
			return false;
		}
		if($('#item_passwd').val() == '')
		{
			messageError('请为用户设置一个初始密码！');
			return false;
		}
		if($('#item_title').val() == '')
		{
			messageError('请填写商家名称！');
			return false;
		}
        if($('#item_homepage').val() == '')
		{
			messageError('请填写商家主页！');
			return false;
		}
        
        if($('#item_bankname').val() == '')
		{
			messageError('请填写开户行！');
			return false;
		}
		
		if($('#item_bankno').val() == '')
		{
			messageError('请填写银行号！');
			return false;
		}
		
		if($('#item_bankuser').val() == '')
		{
			messageError('请填写开户名！');
			return false;
		}
		
		if($('#item_contact').val() == '')
		{
			messageError('请填写联系方式！');
			return false;
		}
		
		if($('#item_address').val() == '')
		{
			messageError('请填写商家地址！');
			return false;
		}
		return true;
	}

	//处理表单
	function formResult(res, status)
	{
		alert(res);
		if(status == 'success')
		{
			if(res == 1)
			{
				messageSuccess('操作已成功！');
				document.getElementById('addform').reset();
				return false;
			}
			else if(res == -10)
			{
				messageError('用户名不能为空！');
				return false;
			}
			else if(res == -11)
			{
				messageError('用户名必须为6到20位字母、数字、汉字、下划线的组合！');
				return false;
			}
			else if(res == -12)
			{
				messageError('用户邮箱不能为空！');
				return false;
			}
            else if(res == -13)
			{
				messageError('邮箱格式不正确！');
				return false;
			}
            else if(res == -14)
			{
				messageError('用户姓名不能为空！');
				return false;
			}
            else if(res == -15)
			{
				messageError('初始密码不能为空！');
				return false;
			}
			else if(res == -16)
			{
				messageError('密码必须为6－20位！');
				return false;
			}
		}
    	else
		{
			messageError('网络异常，请检查网络连接！');
		} 
		return true;
	}
	
	//生成随机的初始密码
	function getFirstWord()
	{
		var pm = {'t':new Date().getTime()};
        var url = geturl('sysuser', 'getWord', pm);

        $.ajax({
			url: url,
			type: 'get',
			dataType: 'html',
			success: function(res){
				//alert(res);
				if(res != ''){
					$('#item_passwd').val(res);
				}
				return true;
			}
		})
	}
	
	$(function(){
		$('#_city').change(function(){
			var self = this;
			var province = $('#_province');
			var locale = $('#_locale');
			province.html('');
			//locale.html('');
			if(!$(self).val()) return;
			$.ajax({
				type:'POST',
				url:'{$DOMAIN_ROOT}/index.php/member/getCityChildren',
				dataType:'json',
				data:'cityid='+$(self).val(),
				success:function(data){
					if(!data.length) return;
					var tmp = '<option >==请选择==</option>';
					for(var i in data){
						var city = data[i];
						tmp += '<option value="'+city.id+'">'+city.name+'</option>';
					}
					province.html(tmp);					
				}
			});
		});
		$('#_province').change(function(){
			var self = this;
			var locale = $('#_locale');
			locale.html('');
			if(!$(self).val()) return;
			$.ajax({
				type:'POST',
				url:'{$DOMAIN_ROOT}/index.php/member/getCityChildren',
				dataType:'json',
				data:'cityid='+$(self).val(),
				success:function(data){
					if(!data.length) return;
					var tmp = '<option >==请选择==</option>';
					for(var i in data){
						var city = data[i];
						tmp += '<option value="'+city.id+'">'+city.name+'</option>';
					}
					locale.html(tmp);					
				}
			});
		});
		
	});

</script>

	<!--表单START-->
	<form name="addform" id="addform" action="" method="post" class="ajaxForm">
	<table width="500"  class="addtbl">
		<tr>
            <td width="50" align="right">登录名称:</td>
            <td width="250">
	            <input type="text" name="item[username]" id="item_username" />
	            <span style="color:red">*</span> <span class="notes">6到20位字母、数字、汉字、下划线的组合</span>
            </td>
        </tr>
		 <tr>
            <td align="right">初始密码:</td>
            <td>
	            <input type="text" name="item[password]" id="item_passwd" style="width:90px" />
				<input type="button" name="first_word" id="first_word" value="生成密码" class="button_1" onclick="getFirstWord()" />
	            <span style="color:red">*</span>
            </td>
        </tr>
        <tr>
            <td align="right">商家名称:</td>
            <td>
	            <input type="text" name="item[title]" id="item_title" style="width:200px;"/>
	            <span style="color:red">*</span>
            </td>
        </tr>
		<tr>
            <td align="right">商家主页:</td>
            <td>
	            <input type="text" name="item[homepage]" id="item_homepage" style="width:300px;"/>
	            <span style="color:red">*</span>
            </td>
        </tr>
		<tr>
            <td align="right">开户行:</td>
            <td>
	            <input type="text" name="item[bankname]" id="item_bankname" style="width:200px;"/>
	            <span style="color:red">*</span>
            </td>
        </tr>
		<tr>
            <td align="right">银行号:</td>
            <td>
	            <input type="text" name="item[bankno]" id="item_bankno" style="width:200px;"/>
	            <span style="color:red">*</span>
            </td>
        </tr>
		<tr>
            <td align="right">开户名:</td>
            <td>
	            <input type="text" name="item[bankuser]" id="item_bankuser" style="width:200px;"/>
	            <span style="color:red">*</span>
            </td>
        </tr>
        <tr>
            <td align="right">联系方式:</td>
            <td>
	            <input type="text" name="item[contact]" id="item_contact" style="width:200px;"/>
	            <span style="color:red">*</span>
            </td>
        </tr>
		 <tr>
		 	<td align="right">所在城市:</td>
            <td>
                <select name="item[city]" id="_city">
                	<option value="">==请选择==</option>
                	<!--{loop $citys $index $one}-->
					<option value="{$index}">{$one}</option>
					<!--{/loop}-->
                </select>省
                <select name="item[province]" id="_province">
                	<option value="">==请选择==</option>
                </select>市
                <select name="item[locale]" id="_locale">
                	<option value="">==请选择==</option>
                </select>区<br/>
				 <span style="color:red">*</span>
            </td>
        </tr>
		<tr>
            <td align="right">商家地址:</td>
            <td>
	            <input type="text" name="item[address]" id="item_address" style="width:300px;"/>
	            <span style="color:red">*</span>
            </td>
        </tr>
		<tr>
            <td align="right">说明:</td>
            <td>
	           <textarea style="width:220px;height:80px;" name="item[notes]"></textarea>
            </td>
        </tr>
        <tr>
			 <td colspan="2" align="center" height="40">
				<input type="submit" name="handin" id="handin" value="提 交" class="button_1" />
			 </td>
		</tr>
	</table>
	</form>
	<!--表单END-->
<!--{include footer_html}-->





